package ec.edu.cec.java.adv.archivos;

import java.io.File;

public class ReadOnlyFile {

	public static void main(String[] args) {
		File file = new File("c:/test/demo1.txt");
		try {
			boolean bool = false;
			bool = file.exists();
			if (bool) {
				bool = file.setReadOnly();
				System.out.println("Set read only file secceeded? "+bool);
				
				//checks whether the file is writable
				bool = file.canWrite();
				System.out.println("File is writable? "+bool);
				
				bool = file.setWritable(true);
				System.out.println("Set writable file succeeded? "+bool);
				
				bool = file.canWrite();
				System.out.println("File is writable? "+bool);
				
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}	

	}

}
